<template>
  <div class="goods_wrap">
    <div class="mygoods_list" v-for="item in productList" :key="item.id">
      <div class="list_title">
        <h1>{{ item.name }}</h1>
        <div>
          <ul>
            <li v-for="navItem in item.children" :key="navItem.id">
              {{ navItem.name }}
            </li>
          </ul>
          <a href="">查看更多</a>
        </div>
      </div>
      <div class="list">
        <div class="list_left">
          <img :src="item.picture" alt="" />
        </div>
        <div class="list_right">
          <div
            class="right_one"
            v-for="proItem in item.goods"
            :key="proItem.id"
          >
            <img :src="proItem.picture" alt="" />
            <p class="pname">{{ proItem.name }}</p>
            <div class="desc">{{ proItem.desc }}</div>
            <div class="price">￥{{ proItem.price }}</div>
            <div class="tips">
              <div>找相似</div>
              <hr />
              <div>发现更多宝贝></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { _getProduct } from '../../../api/home'
export default {
  data () {
    return {
      productList: []
    }
  },
  created () {
    this.getProduct()
  },
  methods: {
    // 获取产品区块接口
    async getProduct () {
      var res = await _getProduct()
      console.log(res)
      this.productList = res.data.result
    }
  }
}
</script>
<style lang="less" scoped>
.goods_wrap {
  width: 1240px;
  margin: 0 auto;
  .mygoods_list {
    width: 100%;
    height: 725px;
  }
  .list_title {
    width: 100%;
    height: 80px;
    line-height: 80px;
    display: flex;
    font-size: 20px;
    justify-content: space-between;
    > div {
      display: flex;
      ul {
        display: flex;
        li {
          width: 120px;
          text-align: center;
          margin-right: 20px;
          &:hover {
            background: #27bb9a;
          }
        }
      }
    }
  }
}
.list {
  width: 1240px;
  height: 625px;
  display: flex;

  .list_left {
    img {
      width: 240px;
      height: 625px;
    }
  }
  .list_right {
    flex: 1;
    margin-left: 20px;
    // background: darkkhaki;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    .right_one {
      width: 178px;
      height: 300px;
      margin-left: 20px;
      overflow: hidden;
      &:hover {
        border: 1px solid #27bb9a;
        box-sizing: border-box;
      }
      &:hover .tips {
        transform: translate(0, -100px);
      }
      .tips {
        height: 100px;
        background: #27bb9a;
        color: white;
        transition: all 0.5s;
      }
      img {
        width: 160px;
        height: 160px;
      }
      .pname {
        font-size: 20px;
        height: 60px;

        overflow: hidden;
        text-overflow: ellipsis;
        // 多行省略号
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }
      .desc {
        color: #ccc;
        height: 30px;
        line-height: 30px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
      .price {
        color: red;
        font-size: 20px;
        margin-bottom: 30px;
      }
    }
  }
}
</style>
